﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace Killboard.Models
{
    public class Banners
    {
        public static List<SelectListItem> GetBanners(string path)
        {
            string []files = Directory.GetFiles(path);

            List<SelectListItem> retval = new List<SelectListItem>();

            string appPath = HttpContext.Current.Server.MapPath("~");

            foreach (string file in files)
            {
                SelectListItem item = new SelectListItem();
                item.Text = Path.GetFileName(file);
                item.Value = string.Format("~{0}", file.Replace(appPath, "").Replace("\\", "/"));
                
                retval.Add(item);
            }

            return retval;
        }

    }
}
